package com.xm.xmapp.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.xm.xmapp.R;
import com.xm.xmapp.app.CodeConstant;
import com.xm.xmapp.app.MyAppcation;
import com.xm.xmapp.base.MyBaseAdapter;
import com.xm.xmapp.base.ViewHolder;
import com.xm.xmapp.myinterface.ListViewOnclickInterFace;
import com.xm.xmapp.response.bean.Get_activity_listResponse;
import com.xm.xmapp.tools.Options;

public class ActivityListAdapter extends
		MyBaseAdapter<Get_activity_listResponse> {

	private ListViewOnclickInterFace in;

	public ActivityListAdapter(ArrayList<Get_activity_listResponse> list,
			Activity activity, int layoutId) {
		super(list, activity, layoutId);

	}

	public ListViewOnclickInterFace getIn() {
		return in;
	}

	public void setIn(ListViewOnclickInterFace in) {
		this.in = in;
	}

	@Override
	public void setValues(ViewHolder holder, final Get_activity_listResponse t,
			int position) {
		
		// holder.setText(R.id.title, t.activity_title)
		// .setText(R.id.content, StringTools.HtmlText(t.activity_content))
		// .setText(R.id.time, t.modified_on);
		//
		// final CustomTextView text = (CustomTextView)
		// holder.getView(R.id.title);
		//
		// if (MyAppcation.getMyAppcation().queryData(
		// CodeConstant.Activity_message, CodeConstant.Activity_id,
		// t.activity_id)) {
		// text.setVisibility(InnerStatus.GONE);
		// } else {
		// text.setVisibility(InnerStatus.VISIBLE);
		// }

		ImageView img = (ImageView) holder.getView(R.id.img);

		switch (t.from) {
		case 1:
			ImageLoader.getInstance().displayImage(t.image, img,
					Options.getListOptions(R.mipmap.app));
			holder.getView(R.id.img2).setVisibility(View.GONE);
			break;
		case 2:
			ImageLoader.getInstance().displayImage(t.image, img,
					Options.getListOptions(R.mipmap.app));
			holder.getView(R.id.img2).setVisibility(View.VISIBLE);
			break;
		default:
			break;
		}
		// ImageLoader.getInstance().
		holder.getConvertView().setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				
				
				MyAppcation.getMyAppcation().insertData(
						CodeConstant.Activity_message,
						CodeConstant.Activity_id, t.activity_id);
				
				if (in != null) {
					in.DoSomeThing(t);
				}
				
				
				

				

			}
		});
	}

}
